package com.asset.dispoal.business.approval.service.converter;

import com.asset.dispoal.business.approval.domain.db.entity.RepaymentApprover;
import com.asset.dispoal.business.approval.domain.db.qo.GetRepaymentApprovalListQo;
import com.asset.dispoal.business.approval.dto.BorrowerInfo;
import com.asset.dispoal.business.approval.dto.GetRepaymentApprovalListRequest;
import com.asset.dispoal.business.approval.dto.OperateItemInfo;
import com.asset.dispoal.business.approval.dto.RepaymentApproverResponse;
import com.asset.dispoal.business.approval.dto.RepaymentInfo;
import com.asset.dispoal.business.bsCase.domain.db.entity.BsCase;
import com.asset.dispoal.business.bsCase.domain.db.entity.BsCaseMediation;
import com.asset.dispoal.business.mediation.domain.db.entity.ReduceStagingTmp;
import com.asset.dispoal.business.repayment.domain.db.entity.BsCaseRepayment;
import com.asset.dispoal.business.repayment.domain.db.entity.BsCaseRepaymentLogs;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @description:
 * @author: yf
 * @date: 2022-10-09 10:43:14
 */
@Mapper
public interface ApprovalConverter {
    ApprovalConverter INSTANCE = Mappers.getMapper(ApprovalConverter.class);

    RepaymentApproverResponse doToRes(RepaymentApprover approver);

    /**
     * 将请求模型转化为查询模型
     *
     * @param request
     * @return
     */
    GetRepaymentApprovalListQo reqToQo(GetRepaymentApprovalListRequest request);

    /**
     * 案件借款人信息提取
     *
     * @param bsCase
     * @return
     */
    BorrowerInfo caseInfoToBorrowInfo(BsCase bsCase);

    OperateItemInfo stageInfoToOperateInfo(ReduceStagingTmp tmp);

    @Mappings({
            @Mapping(target = "principalAmount", source = "prepaymentPrincipal"),
            @Mapping(target = "interestAmount", source = "prepaymentInterest"),
            @Mapping(target = "litigationFines", source = "prepaymentPenalty"),
            @Mapping(target = "period", source = "period"),
            @Mapping(target = "repaymentTime", source = "prepaymentTime")
    })
    OperateItemInfo meditionInfoToOperateInfo(BsCaseMediation mediation);

    OperateItemInfo repaymentInfoToOperateInfo(BsCaseRepayment caseRepayment);

    RepaymentInfo repaymentLogInfoToRepaymentInfo(BsCaseRepaymentLogs repaymentLogs);
}
